﻿@using WebEntities.Models.Framework;
@using WebEntities;

@model List<FW_MemberMenu>

@{
    ViewBag.Title = "网站管理平台";
}

@section HeadContent
{
    <link href="/Content/modual-view.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
        var addTab = function (tabPanel, id, url, menuItem) {
            var tab = tabPanel.getComponent(id);
            if (!tab) {
                tab = tabPanel.add({
                    id: id,
                    title: menuItem.text,
                    closable: true,
                    menuItem: menuItem,
                    loader: {
                        url: url,
                        renderer: "frame",
                        loadMask: {
                            showMask: true,
                            msg: "Loading " + url + "..."
                        }
                    }
                });
            }
            tabPanel.setActiveTab(tab);
        }

        var addTab2 = function (tabPanel, id, url, title) {
            var tab = tabPanel.getComponent(id);
            if (!tab) {
                tab = tabPanel.add({
                    id: id,
                    title: title,
                    closable: true,
                    loader: {
                        url: url,
                        renderer: "frame",
                        loadMask: {
                            showMask: true,
                            msg: "Loading " + url + "..."
                        }
                    }
                });
            }
            tabPanel.setActiveTab(tab);
        }
    </script>
}

@(Html.X().Viewport()
    .Layout(LayoutType.Border)
    .Items(
        Html.X().Panel()
            .Border(false)
            .BodyStyle("background-color:#e0e0e0")
            .Padding(2)
            .Region(Region.North)
            .Layout(LayoutType.Column)
            .Items(
                Html.X().Label("网站管理平台").Icon(Icon.Eyes)
                    .ColumnWidth(0.5)
                    .StyleSpec("font-weight:bold"),
                Html.X().Container().ColumnWidth(0.5).StyleSpec("text-align:right")
                    .Items(
                        Html.X().Label().Text(HttpContext.Current.User.Identity.Name).Icon(Icon.User).PaddingSpec("0 10 0 0"),
                        Html.X().Button().Text("注销").Icon(Icon.LockGo).DirectClickAction("Logout")
                    )
            ),
        Html.X().Panel()
            .Region(Region.West)
            .Width(200)
            .Title("浮动菜单栏")
            .Collapsible(true)
            .Split(true)
            .MinWidth(175)
            .MaxWidth(400)
            .MarginSpec("5 0 5 5")
            .Layout(LayoutType.Accordion)
            .Items(it =>
            {
                List<FW_MemberMuItem> memMuItemlist = ViewBag.MemberMuItemList as List<FW_MemberMuItem>;
                foreach (var memMenu in Model)
                {
                    FW_Menu menu = memMenu.FW_Menu;
                    it.Add(Html.X().MenuPanel()
                        .Icon(Icon.Note)
                        .Title(menu.MenuName)
                        .Menu(mu =>
                        {
                            if (memMuItemlist != null)
                            {
                                //找出栏目菜单的子菜单
                                var query = memMuItemlist.Where(c => c.FW_MenuItem.MenuID == menu.MenuID);
                                foreach (var mitem in query)
                                {
                                    mu.Add(Html.X().MenuItem()
                                        .Text(mitem.FW_MenuItem.ItemName)
                                        .Icon(Icon.ApplicationForm)
                                        .Listeners(ls =>
                                        {
                                            ls.Click.Handler = "addTab(#{TabPanel1}, 'idClt" + mitem.FW_MenuItem.ItemID + "', '" + mitem.FW_MenuItem.ItemUrl + "', this);";
                                        })
                                    );
                                }
                            }
                        })
                    );
                }
            }),

        Html.X().TabPanel()
            .ID("TabPanel1")
            .IDMode(IDMode.Explicit)
            .Region(Region.Center)
            .MarginSpec("5 5 5 0")
            .Layout(LayoutType.Fit)
            .Items(
                Html.X().Panel().Title("网站后台管理主页")
                    .Items(
                        Html.X().FieldSet()
                            .Collapsible(true)
                            .Title("登录用户信息")
                            .Margin(5)
                            .Layout(LayoutType.Fit)
                            .Loader(
                                Html.X().ComponentLoader()
                                    .Url(Url.Action("LoginUserInfo"))
                                    .Mode(LoadMode.Frame)
                                    .LoadMask(lm =>
                                    {
                                        lm.ShowMask = true;
                                        lm.Msg = "加载中，请稍候...";
                                    })
                            )
                    )

            )
    )
)
